package com.cat.dataStructure;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/maximum-total-subarray-value-i/
 * @create 2025/9/21 16:15
 * @since JDK17
 */

public class Solution70 {
    public long maxTotalValue(int[] nums, int k) {
        int max = Integer.MIN_VALUE, min = Integer.MAX_VALUE, n = nums.length;
        for (int i = 0; i < n; i++) {
            max = Math.max(max, nums[i]);
            min = Math.min(min, nums[i]);
        }
        return (long)(max - min) * k;
    }
}
